package com.tushu.dao;

import com.tushu.model.Admin;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class AdminDao extends BaseDAO{
    //查询所有
    public List<Admin> selectAdminList(){
        String sql = "select * from tb_admin";
        return super.selectAll(sql, new Object[]{});
    }

    //通过账号查询一个用户
    public Admin selectAdmin(String account) {
        String sql = "select * from tb_admin where account=?";
        return super.select(sql,new Object[] {account});
    }
    @Override
    public Admin rowMapper(ResultSet rs) throws SQLException {
        Admin admin = new Admin();
        admin.setId(rs.getInt("id"));
        admin.setAccount(rs.getString("account"));
        admin.setPassword(rs.getString("password"));
        admin.setName(rs.getString("name"));
        return admin;
    }
}
